public class LeetCode392 {
    public static void main(String[] args) {
        boolean subsequence = isSubsequence("axc", "ahbgdc");
        System.out.println(subsequence);
    }
    public static boolean isSubsequence(String s, String t) {
        //1.准备两个指针，指向两个字符串
        int sp = 0,tp =0;
        //2.以子序列字符串为准，字符串如果找到了一个，则子序列指针前进1，必须按顺序，如果最后子序列指针都没有走完说明不是子序列

        while (true){
            if (s.length() == sp){
                return true;
            }
            if (t.length() == tp){
                return false;
            }
            if (s.charAt(sp) == t.charAt(tp)){
                sp++;
            }
            tp++;
        }
    }
}
